# coding: utf-8

from settings import REDIS_HOST, REDIS_PORT

# 产生的任务放到这里 队列
BROKER_BACKEND = 'redis'
# 任务队列
BROKER_URL = f'redis://{REDIS_HOST}:{REDIS_PORT}/1'
# 结果保存
CELERY_RESULT_BACKEND = f'redis://{REDIS_HOST}:{REDIS_PORT}/2'

# 有些情况可以防止死锁
CELERYD_FORCE_EXECV = True
# 设置并发worker数量
CELERYD_CONCURRENCY = 4
# 允许重试
CELERY_ACKS_LATE = True
# 每个worker最多执行100个任务被销毁，可以防止内存泄漏
CELERYD_MAX_TASKS_PER_CHILD = 100
# 超时时间
CELERYD_TASK_TIME_LIMIT = (60 * 60)

# celery worker每次去redis取任务的数量，默认值就是4
CELERYD_PREFETCH_MULTIPLIER = 4

# 时区
celery_timezone = 'Asia/shanghai'
CELERY_ENABLE_UTC = True
# 任务文件
CELERY_IMPORTS = (
    'celery_app.tasks',
)
